﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_bidTable : System.Web.UI.Page
{
    public string ProjectId;
    protected void Page_Load(object sender, EventArgs e)
    {
        string strSql, delBidTableId;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (SysFun.ToTrim(Request.QueryString["ProjectId"]) == "")
            {
                ProjectId = "1";
            }
            else
            {
                ProjectId = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["ProjectId"]));
            }
            if (Request.Form["btnSubmit"] == "删除" && Request.Form["chk"] != null)
            {
                delBidTableId = Request.Form["chk"].ToString();
                strSql = "delete from bidTable where BidTableId in (" + delBidTableId + ")";
                Db db = new Db();
                db.Command(strSql);
                db.Close();
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "删除", "bidTable", strSql, "../Agency/bidTable.aspx");

            }
            showGridView();
        }
    }


    /// <summary>
    /// 将数据绑定到datalist
    /// </summary>
    public void showGridView()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "BidTable";                                               //要查询的表明
        dbPage.Key = "BidTableId";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "BidTableId,ProjectId,BidTableName,BidTableType,BidTableOutlookc,ProductCode,ZL1,HL1";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 20;                                                    //没有显示记录条数   
        dbPage.OrderBy = "BidTableName,BidTableType,BidTableOutlookc";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        dtlProduct.DataSource = dr;
        dtlProduct.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键

    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        string strtemp, BidTableName, BidTableType, BidTableOutlookc, ProductCode = "", _ZL1, _HL1;
        BidTableName = txtname.Text.ToString().Trim();
        BidTableType = txtmedicinemodel.Text.ToString().Trim();
        BidTableOutlookc = txtoutlook.Text.ToString().Trim();
        ProductCode = txtProductCode.Text.ToString().Trim();
        _ZL1 = txtZL1.Text.ToString().Trim();
        _HL1 = txtHL1.Text.ToString().Trim();
        strtemp = "";
        if (_ZL1 != "")
        {
            strtemp = strtemp + " ZL1 = " + _ZL1 + " and";
        }
        if (_HL1 != "")
        {
            strtemp = strtemp + " HL1 = " + _HL1 + " and";
        }
        if (BidTableName != "")
        {
            strtemp = strtemp + " BidTableName like '%" + BidTableName + "%' and";
        }
        if (BidTableType != "")
        {
            strtemp = strtemp + " BidTableType like '%" + BidTableType + "%' and";
        }
        if (BidTableOutlookc != "")
        {
            strtemp = strtemp + " BidTableOutlookc like '%" + BidTableOutlookc + "%' and";
        }
        if (ProductCode != "")
        {
            strtemp = strtemp + " ProductCode like '%" + ProductCode + "%' and";
        }
        if (strtemp != "")
        {
            strtemp = "  " + strtemp.Substring(0, strtemp.Length - 3);
        }
        return strtemp;

    }


}
